package com.leetcode.algorithm.y22.m07.w3;

import com.leetcode.algorithm.common.ListNode;
import com.leetcode.algorithm.common.TreeNode;

/**
 * 1367. 二叉树中的列表
 * 
 * https://leetcode.cn/problems/linked-list-in-binary-tree/
 * 
 * @author jie.deng
 *
 */
class Question1367Solution02 {

	// WARNING:错误的写法
	public boolean isSubPath(ListNode head, TreeNode root) {
		if (head == null) {
			return true;
		}
		if (root == null) {
			return false;
		}
		if (root.val == head.val) {
			if (isSubPath(head.next, root.left) || isSubPath(head.next, root.right)) {
				return true;
			}
		}
		return isSubPath(head, root.left) || isSubPath(head, root.right);
	}

}